﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DecisionTree
{
    class LightDecisionNode
    {
        public int IndexCount { get; private set; }
        public LightDecisionNode Parent { get; private set; }
        public int Level { get; private set; }

        public LightDecisionNode[] Branches { get; set; }

        public int SplitFeature;
        public int? Output;
        public double[] OutputHistogram;

        public bool IsRoot
        {
            get { return Parent == null; }
        }

        public bool IsLeaf
        {
            get { return Branches == null || Branches.Length == 0; }
        }

        public LightDecisionNode(LightDecisionNode parent) { this.Parent = parent; }

        public void SetValues(LightDecisionNode[] branches, int indexCount, int level, int splitFeature, int? output, double[] outputHistogram)
        {
            this.Branches = branches;
            this.IndexCount = indexCount;
            this.Level = level;
            this.SplitFeature = splitFeature;
            this.Output = output;
            this.OutputHistogram = outputHistogram;
        }

        public bool IsValid(byte[] p)
        {
            if (p[SplitFeature] == 0)
                return true;
            return false;
        }
    }
}
